// 查询
//var Excute = require('./excute.js');
//var excute = new Excute(__dirname);
var db     = require('./db.js');
function queryObject(sql) {
	console.log('sql start');
	if (arguments.length === 2) {
		sqlParam = [];
		res = arguments[1];
	} else {
		sqlParam = arguments[1];
		res = arguments[2];
	}
	db.execQuery({
		sql : sql ,
		args: sqlParam,
		handler: handler
	});
}

function handler(result){
	if (!result) {
		console.log(result);
	}
	res.setHeader('content-type', 'text/plain;charset=utf-8');
  res.write( JSON.stringify(result[0]) );
	res.end();
}

module.exports = queryObject;